/*! layui-v2.6.8 | (c) 2021 Layui Community | MIT License */
// Simplified Layui for basic layer functionality
window.layui = (function() {
    'use strict';

    var layui = {
        v: '2.6.8'
    };

    // Layer module for notifications
    layui.layer = {
        msg: function(content, options, end) {
            options = options || {};
            var defaults = {
                time: 2000,
                icon: 0,
                area: 'auto',
                closeBtn: 0,
                btn: false,
                resize: false,
                shade: false
            };
            
            var config = Object.assign(defaults, options);
            
            // Create message element
            var msgId = 'layui-msg-' + Date.now();
            var msgHtml = '<div id="' + msgId + '" class="layui-layer layui-layer-msg" style="' +
                'position: fixed; z-index: 19891015; background: rgba(0,0,0,.7); color: #fff; ' +
                'padding: 10px 15px; border-radius: 5px; font-size: 12px; ' +
                'top: 50%; left: 50%; transform: translate(-50%, -50%); ' +
                'max-width: 300px; text-align: center;">' + content + '</div>';
            
            document.body.insertAdjacentHTML('beforeend', msgHtml);
            
            // Auto close
            setTimeout(function() {
                var msgEl = document.getElementById(msgId);
                if (msgEl) {
                    msgEl.remove();
                }
                if (typeof end === 'function') {
                    end();
                }
            }, config.time);
            
            return msgId;
        },
        
        alert: function(content, options, yes) {
            if (typeof options === 'function') {
                yes = options;
                options = {};
            }
            
            var alertId = 'layui-alert-' + Date.now();
            var alertHtml = '<div id="' + alertId + '" class="layui-layer layui-layer-dialog" style="' +
                'position: fixed; z-index: 19891016; background: #fff; ' +
                'top: 50%; left: 50%; transform: translate(-50%, -50%); ' +
                'min-width: 260px; border-radius: 5px; box-shadow: 0 2px 8px rgba(0,0,0,.15);">' +
                '<div style="padding: 20px; text-align: center;">' + content + '</div>' +
                '<div style="text-align: center; padding: 10px; border-top: 1px solid #e2e2e2;">' +
                '<button onclick="layui.layer.close(\'' + alertId + '\')" style="' +
                'background: #5FB878; color: #fff; border: none; padding: 8px 20px; ' +
                'border-radius: 3px; cursor: pointer;">确定</button>' +
                '</div></div>';
            
            // Add backdrop
            var backdropId = alertId + '-backdrop';
            var backdropHtml = '<div id="' + backdropId + '" style="' +
                'position: fixed; top: 0; left: 0; width: 100%; height: 100%; ' +
                'background: rgba(0,0,0,0.3); z-index: 19891015;"></div>';
            
            document.body.insertAdjacentHTML('beforeend', backdropHtml);
            document.body.insertAdjacentHTML('beforeend', alertHtml);
            
            return alertId;
        },
        
        close: function(id) {
            var el = document.getElementById(id);
            if (el) {
                el.remove();
            }
            var backdrop = document.getElementById(id + '-backdrop');
            if (backdrop) {
                backdrop.remove();
            }
        }
    };

    // Export layer globally
    window.layer = layui.layer;

    return layui;
})();